package cc.lj.internal.mobilepay.domain.service.impl;

import cc.lj.internal.mobilepay.domain.model.vo.CiticLogDO;
import cc.lj.internal.mobilepay.domain.model.vo.convert.CiticLogPOConvertDO;
import cc.lj.internal.mobilepay.domain.repository.ICiticLogRepository;
import cc.lj.internal.mobilepay.domain.service.ICiticLogDomainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 中信请求响应日志表 domain service 实现
 * @author liangxifeng
 * @date 2022/11/25 17:10
 */

@Service("citicLogDomainServiceImpl")
@Slf4j
public class CiticLogDomainServiceImpl implements ICiticLogDomainService {

    @Resource(name = "citicLogResponsitory")
    private ICiticLogRepository citicLogRepository;

    @Override
    public Integer save(CiticLogDO entityDO) {
        return citicLogRepository.insert( CiticLogPOConvertDO.INSTANCE.convert(entityDO) );
    }

    @Override
    public Integer updateById(CiticLogDO entityDO) {
        return citicLogRepository.updateById(CiticLogPOConvertDO.INSTANCE.convert(entityDO));
    }

    @Override
    public CiticLogDO getById(Integer id) {
        return CiticLogPOConvertDO.INSTANCE.convert( citicLogRepository.getById(id) );
    }

    @Override
    public List<CiticLogDO> getList(CiticLogDO entityDO) {
        return citicLogRepository.getList(CiticLogPOConvertDO.INSTANCE.convert(entityDO))
                .stream().map( x -> CiticLogPOConvertDO.INSTANCE.convert(x))
                .collect(Collectors.toList());
    }

    @Override
    public Integer deleteById(Integer id) {
        return citicLogRepository.deleteById(id);
    }
}
